package study.rpc.dubbo.provider.support.filter;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.RpcException;

@Slf4j
@Activate(group = CommonConstants.PROVIDER, order = 2)
public class ProviderFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        log.info(">>>>>> provider filter");
        Result result;
        try {
            result = invoker.invoke(invocation);
        } catch (RpcException ex) {
            throw ex;
        } finally {
            log.info(">>>>>> provider filter");
        }
        return result;
    }
}
